package com.pany.rememberpass;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.widget.ListView;
import android.widget.SimpleAdapter;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class SimpleActivity extends AppCompatActivity {

    private ListView lv;
    private List<Map<String, Object>> mapList;
    private int[] iamges = {
            R.drawable.test1,
            R.drawable.test2,
            R.drawable.test3,
            R.drawable.test4,
            R.drawable.test5,
            R.drawable.test6,
            R.drawable.test7,
            R.drawable.test8,
            R.drawable.test9
    };

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_simple);

        lv = findViewById(R.id.lv);
        mapList = new ArrayList<>();

        for (int i = 0; i < 50; i++) {
            Map<String, Object> hashMap = new HashMap<>();
            hashMap.put("iamge", iamges[i % iamges.length]);
            hashMap.put("title", "这是标题" + i);
            hashMap.put("content", "这是内容" + i);
            mapList.add(hashMap);
        }
        SimpleAdapter simpleAdapter = new SimpleAdapter(this, mapList,
                R.layout.list_item_layout,
                new String[]{"iamge", "title", "content"}, new int[]{R.id.iv_img, R.id.tv_title, R.id.tv_content});

        lv.setAdapter(simpleAdapter);

    }
}